package com.block.merchant.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum ShowPositionEnum {

    ALL("ALL", "全部展示")
    ,PAGE("PAGE", "授权页展示")
    ,LIST("LIST", "列表展示")
    ;

    private String value;
    private String name;

    public static List<Map<String, String>> getMapList(){
        List<Map<String, String>> resultList = new ArrayList<>();
        for (ShowPositionEnum actionTypeEnum : values()) {
            Map<String, String> itemMap = new HashMap<>();
            itemMap.put("key", actionTypeEnum.getName());
            itemMap.put("value", String.valueOf(actionTypeEnum.getValue()));
            resultList.add(itemMap);
        }
        return resultList;
    }

    ShowPositionEnum(String value, String name){
        this.value = value;
        this.name = name;
    }

    public static String getNameByValue(String value){
        for (ShowPositionEnum typeEnum : values()) {
            if (ObjectUtil.equals(typeEnum.getValue(), value)){
                return typeEnum.getName();
            }
        }
        return null;
    }
}
